package com.zyf.service.serviceImpl;

import com.zyf.dao.daoImpl.daoImpl;
import com.zyf.entity.book;
import com.zyf.service.service;
import com.zyf.util.DButil;

import java.sql.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class serviceImpl implements service {
    public serviceImpl() {

    }

    daoImpl di = new daoImpl();

    @Override
    public List<book> listAllbook() {
        return di.findBook(new HashMap<String,String>());

    }

    @Override
    public List<book> findBookByName(String bookName) {
        Map<String,String> map = new HashMap<>();
        map.put("bookname",bookName);
        return di.findBook(map);
    }

    @Override
    public List<book> findBookByAuther(String Auther) {
        Map<String,String> map = new HashMap<>();
        map.put("bookauther",Auther);
        return di.findBook(map);
    }

    @Override
    public List<book> findBookByLocation(String location) {
        Map<String,String> map = new HashMap<>();
        map.put("booklocation",location);
        return di.findBook(map);
    }

    @Override
    public book findBookById(int id) {
        return di.findById(id);
    }


    @Override
    public int deleteBookById(int id) {
        return di.deleteBook(id);
    }

    @Override
    public int insertNewBook(book abookWithoutId) {
        return di.insertBook(abookWithoutId);
    }

    @Override
    public int setName(int id, String Name) {
        Map<String,String> map = new HashMap<String,String>();
        map.put("bookName",Name);
        return di.setProperties(id,map);
    }

    @Override
    public int setAuther(int id, String Auther) {
        Map<String,String> map = new HashMap<String, String>();
        map.put("bookAuther",Auther);
        return di.setProperties(id,map);
    }

    @Override
    public int setLocation(int id, String Location) {
        Map<String,String> map = new HashMap<String, String>();
        map.put("booklocation",Location);
        return di.setProperties(id,map);
    }


    @Override
    public int updateDate(int id, Date sqldate) {
        return di.refreshEnterDate(id,sqldate);
    }
}
